package com.example.demo.rest;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.MessageDigestPasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author void
 * @date 2020/12/7 19:44
 * @desc 用户操作自身接口，校验本人
 */
@RestController
@RequestMapping("/user/api")
public class UserController {

    @GetMapping("/hello")
    public String hello(){
        return "hello, user";
    }

    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        List<String> passwdList = new ArrayList<>();
        for(int i=0; i<10;i++){
            String s = encoder.encode("123456");
            System.out.println(s);
            passwdList.add(s);
        }

        for (String s : passwdList) {
            System.out.println(encoder.matches("123456", s));
        }
    }
}
